package com.qianqutech.plugin.captcha.captchaUtil.service;

import com.qianqutech.plugin.captcha.captchaUtil.level.Level;
import com.qianqutech.plugin.captcha.captchaUtil.renderer.BestFitTextRenderer;
import com.qianqutech.plugin.captcha.captchaUtil.service.background.impl.SingleColorBackgroundFactory;
import com.qianqutech.plugin.captcha.captchaUtil.service.color.impl.SingleColorFactory;
import com.qianqutech.plugin.captcha.captchaUtil.service.font.impl.RandomFontFactory;
import com.qianqutech.plugin.captcha.captchaUtil.service.word.impl.AdaptiveRandomWordFactory;

import java.awt.*;


public class SimpleCaptchaService extends AbstractCaptchaService {

	public SimpleCaptchaService(Level level) {
		backgroundFactory = new SingleColorBackgroundFactory(new Color(250, 90, 170));
		wordFactory = new AdaptiveRandomWordFactory(level,null);
		fontFactory = new RandomFontFactory();
		textRenderer = new BestFitTextRenderer();
		colorFactory = new SingleColorFactory(new Color(25, 60, 170));
	}

	public SimpleCaptchaService(Level level,Color backgroundColor) {
		backgroundFactory = new SingleColorBackgroundFactory(backgroundColor);
		wordFactory = new AdaptiveRandomWordFactory(level,null);
		fontFactory = new RandomFontFactory();
		textRenderer = new BestFitTextRenderer();
		colorFactory = new SingleColorFactory(new Color(25, 60, 170));
	}

	public SimpleCaptchaService(Level level,Integer maxLength) {
		backgroundFactory = new SingleColorBackgroundFactory(new Color(250, 90, 170));
		wordFactory = new AdaptiveRandomWordFactory(level,maxLength);
		fontFactory = new RandomFontFactory();
		textRenderer = new BestFitTextRenderer();
		colorFactory = new SingleColorFactory(new Color(25, 60, 170));
	}

	public SimpleCaptchaService(Level level,Color backgroundColor,Integer maxLength) {
		backgroundFactory = new SingleColorBackgroundFactory(backgroundColor);
		wordFactory = new AdaptiveRandomWordFactory(level,maxLength);
		fontFactory = new RandomFontFactory();
		textRenderer = new BestFitTextRenderer();
		colorFactory = new SingleColorFactory(new Color(25, 60, 170));
	}

	/*public SimpleCaptchaService() {
		backgroundFactory = new SingleColorBackgroundFactory();
		wordFactory = new AdaptiveRandomWordFactory();
		fontFactory = new RandomFontFactory();
		textRenderer = new BestFitTextRenderer();
		colorFactory = new SingleColorFactory();
		textRenderer.setLeftMargin(10);
		textRenderer.setRightMargin(10);
		width = 160;
		height = 70;
	}*/

	public SimpleCaptchaService(int width, int height, Color textColor, Color backgroundColor,
								int fontSize, String[]fontNames) {
		backgroundFactory = new SingleColorBackgroundFactory(backgroundColor);
		wordFactory = new AdaptiveRandomWordFactory(Level.getHARD,null);
		fontFactory = new RandomFontFactory(fontNames);
		textRenderer = new BestFitTextRenderer();
		colorFactory = new SingleColorFactory(textColor);
		this.width = width;
		this.height = height;
	}
	
	@Override
	public Captcha getCaptcha() {
		return super.getCaptcha();
	}

}
